<template>
  <div>
    <h1>我是count</h1>
    <h5>我是count的{{count}}</h5>
    <button @click="add">每次加1按钮</button>
    <button @click="addN({n:10})">每一次加10</button>

  </div>
</template>

<script>
import { mapMutations, mapState } from "vuex";
export default {
  name: "Count",
  computed: {
    ...mapState("count",["count"]),
  },
  methods:{
    addN({n}){
        //传参方式使用commit
        this.$store.commit("count/addN" ,{n})
    },
    //不传参直接使用mapMutations
    ...mapMutations("count",["add"])
  }
};
</script>

<style>
</style>